<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
      <el-form-item label="起止时间">
        <el-date-picker
          v-model="dateRange"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="单据号" prop="roleName">
        <el-input v-model="queryParams.input" placeholder="请输入" />
      </el-form-item>
      <el-form-item label="单位名称" prop="roleName">
        <el-input v-model="queryParams.input" placeholder="请输入" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button @click="handleAdd" size="mini">新增</el-button>
        <el-button @click="handleEdit" size="mini">编辑</el-button>
        <el-button @click="handleDelete" size="mini">删除</el-button>
        <el-button size="mini">附件</el-button>
        <el-button size="mini">提交</el-button>
      </el-col>
    </el-row>
    <el-table v-loading="loading" :data="list" @row-click="rowSelect" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="序号" type="index" :index="indexMethod" width="80" />
      <el-table-column label="状态" prop="roleKey" />
      <el-table-column label="单据号" prop="roleKey" />
      <el-table-column label="制单日期" prop="roleKey" />
      <el-table-column label="单位名称" prop="roleKey" />
      <el-table-column label="结算单位" prop="roleKey" />
      <el-table-column label="制单人" prop="roleKey" />
      <el-table-column label="当前审核人" prop="roleKey" />
      <el-table-column label="审核日期" prop="roleKey" />
      <el-table-column label="弃审备注" prop="roleKey" />
    </el-table>

    <el-table v-loading="loading1" :data="list1">
      <el-table-column label="合同单据号" prop="roleKey" />
      <el-table-column label="费用单据号" prop="roleKey" />
      <el-table-column label="费用名称" prop="roleKey" />
      <el-table-column label="申请减免金额" prop="roleKey" />
      <el-table-column label="备注" prop="roleKey" />
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { listRole } from "@/api/system/role";

export default {
  data() {
    return {
      ids: [],
      // 下拉数据
      options: [],
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 表格数据
      list: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10
      },
      // 起止日期
      dateRange: [],
      // 子表
      loading: false,
      list1: []
    };
  },
  created() {
    this.getList();
  },
  methods: {
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.roleId)
    },
    // 序号计算
    indexMethod(index) {
      return (this.queryParams.pageNum- 1) * this.queryParams.pageSize + index + 1;
    },
    /** 查询角色列表 */
    getList() {
      this.loading = true;
      listRole(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
          this.list = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = []
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 表格行点击
    rowSelect(row) {
      this.loading1 = true
      this.list1 = []
      this.loading1 = false
    }
  }
};
</script>
